package com.qianfeng.ls.web;


import com.qianfeng.ls.entity.UserEntity;
import com.qianfeng.ls.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.DriverManager;
import java.sql.PreparedStatement;

@Controller
public class UserController {

    @Autowired
    IUserService userService;

    @RequestMapping("/login")
    @ResponseBody
    public String login(UserEntity ue){

        if(null != userService.login(ue)){
            return "0000";
        }

        return "用户名密码错误";
    }

    @RequestMapping("/transfer")
    public String transfer(String uid1,String uid2,float money){

        boolean result = userService.transfer(uid1,uid2,money);

        if(result){
            System.out.println("success");
        }else{
            System.out.println("faild");
        }

        return "success";
    }

    @RequestMapping("/index")
    public String index(){
        return "index";
    }
    @RequestMapping("/welcome")
    public String welcome(){
        return "welcome";
    }

}
